package cn.iocoder.yudao.framework.business.basic.pojo.bo;

import com.fasterxml.jackson.annotation.JsonIgnore;

import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

/**
 * <pre>
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 *  经营时间
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * </pre>
 *
 * @author 山野羡民（1032694760@qq.com）
 * @since 2024/12/05
 */
public interface BusinessHours {

    /**
     * 格式化经营时间
     *
     * @param openingTime 营业时间
     * @param closingTime 打烊时间
     */
    @JsonIgnore
    default String formatBusinessHours(LocalTime openingTime, LocalTime closingTime) {
        if (openingTime == null && closingTime == null) {
            return "";
        }
        String openingTimeStr = "--:--";
        if (openingTime != null) {
            openingTimeStr = openingTime.format(DateTimeFormatter.ofPattern("HH:mm"));
        }
        String closingTimeStr = "--:--";
        if (closingTime != null) {
            closingTimeStr = closingTime.format(DateTimeFormatter.ofPattern("HH:mm"));
        }
        return openingTimeStr + "-" + closingTimeStr;
    }

}
